import { ApiRes } from '@/types/data'
import { GoodsInfo } from '@/types/goods'
import request from '@/utils/request'
import { defineStore } from 'pinia'

const useGoodsStore = defineStore('goods', {
	state: () => {
		return {
			// 商品信息
			info: {} as GoodsInfo,
		}
	},
	actions: {
		async getGoodsInfo(id: string) {
			const res = await request.get<ApiRes<GoodsInfo>>('/goods', { params: { id } })
			this.info = res.data.result
		},
	},
	getters: {},
})

export default useGoodsStore
